home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 43 / Amiga Format CD43 (1999)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-09].iso / -serious- / archivers / xpk / xpk_source / xpkmaster / objects.c < prev    next >
C/C++ Source or Header  |  1999-06-14  |  2KB  |  66 lines

  1. #ifndef XPKMASTER_OBJECTS_C
  2. #define XPKMASTER_OBJECTS_C
  3.  
  4. /* Routinesheader
  5.  
  6.     Name:        objects.c
  7.     Main:        xpkmaster
  8.     Versionstring:    $VER: objects.c 1.2 (21.02.1998)
  9.     Author:        SDI
  10.     Distribution:    Freeware
  11.     Description:    object allocation functions and prefs sem get funcs
  12.  
  13.  1.0   27.12.96 : first version
  14.  1.1   09.01.98 : added XPK_ALLINONE
  15.  1.2   21.02.98 : uses new style register definition
  16. */
  17.  
  18. #include <proto/exec.h>
  19. #include <exec/memory.h>
  20. #include <xpk/xpk.h>
  21. #include <xpk/xpkprefs.h>
  22. #include "xpkmaster.h"
  23.  
  24. XPK_ALLINONE struct XpkPrefsSemaphore *GetPrefsSem(void)
  25. {
  26.   struct XpkPrefsSemaphore *sem;
  27.   Forbid();
  28.   if((sem = (struct XpkPrefsSemaphore *) FindSemaphore(XPKPREFSSEMNAME)))
  29.     ObtainSemaphoreShared((struct SignalSemaphore *) sem);
  30.   Permit();
  31.   
  32.   return sem;
  33. }
  34.  
  35. static ULONG GetXpkObjectSize(ULONG type)
  36. {
  37.   switch(type)
  38.   {
  39.   case XPKOBJ_FIB:        return sizeof(struct XpkFib); break;
  40.   case XPKOBJ_PACKERINFO:    return sizeof(struct XpkPackerInfo); break;
  41.   case XPKOBJ_MODE:        return sizeof(struct XpkMode); break;
  42.   case XPKOBJ_PACKERLIST:    return sizeof(struct XpkPackerList); break;
  43.   };
  44.   return 0;
  45. }
  46.  
  47. ASM(APTR) LIBXpkAllocObject(REG(d0, ULONG type), REG(a0, struct TagItem *tags))
  48. {
  49.   ULONG size;
  50.   
  51.   if((size = GetXpkObjectSize(type)))
  52.     return AllocMem(size, MEMF_PUBLIC|MEMF_CLEAR);
  53.  
  54.   return 0;
  55. }
  56.  
  57. ASM(void) LIBXpkFreeObject(REG(d0, ULONG type), REG(a0, APTR object))
  58. {
  59.   ULONG size;
  60.   
  61.   if((size = GetXpkObjectSize(type)))
  62.     FreeMem(object, size);
  63. }
  64.  
  65. #endif    /* XPKMASTER_OBJECTS_C */
  66.